package com.team11.server.service.admin;


import com.team11.server.mapper.Admin_Insert_C_Mapper;
import com.team11.server.pojo.C_T_S_information;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class Admin_Insert_C_Service {
    @Autowired
    private Admin_Insert_C_Mapper admin_insert_c_mapper;
    public String Insert_C(C_T_S_information c_t_s_information){
        String tN=c_t_s_information.getTName();
        String[] tArray=tN.split("-");
        String tNumber=tArray[0];
        String tName=tArray[1];
        c_t_s_information.setTJobNumber(tNumber);
        c_t_s_information.setTName(tName);
        Integer o=admin_insert_c_mapper.Sel_T_In_C(c_t_s_information);
        if (o==null) {
            return "教师不存在";
        }
        else {
            c_t_s_information.setTId(admin_insert_c_mapper.Sel_T_In_C(c_t_s_information));

        }
        Integer t=admin_insert_c_mapper.Insert_C(c_t_s_information);
        if (t>0){
            return "插入成功";
        }
        else {
            return "插入失败";
        }
    }
    public String Have_C(C_T_S_information c_t_s_information){
        Integer t=admin_insert_c_mapper.Sel_have_C(c_t_s_information);
        if (t>0){
            return "班级已存在";
        }
        else {
            return "1";
        }
    }

}
